<?php

class Api {

    var $apiurl;
    var $data = array();
    var $clienttype;

    function Api($clienttype) {
        $this->clienttype = $clienttype;
        if ($this->clienttype == 'account') {
            $this->apiurl = Yii::app()->params['apiUrlAccount'];
        } elseif ($this->clienttype == 'product') {
            $this->apiurl = Yii::app()->params['apiUrlProduct'];
        }
        
    }
    
    function apiclient($apiname,$data=false){
        $client = new HttpClient($this->clienttype);
        if($client->post($this->apiurl . $apiname, $data)){
            $putout = CJSON::decode($client->getContent());
        }else{
            $putout = 0;
        }
        return $putout;
    }
}

?>